﻿using System;

namespace TopoViewer
{
    /// <summary>
    /// Represents a rectangle in the world coordinates.
    /// </summary>
    public struct GRect
    {
        /// <summary>
        /// Boundaries of the rectangle, in seconds.
        /// </summary>
        public double north, west, south, east;

        public GRect(double n, double w, double s, double e)
        {
            west = w;
            north = n;
            east = e;
            south = s;
        }

        public static GRect operator &(GRect rect1, GRect rect2)
        {
            GRect result;
            result.west = Math.Max(rect1.west, rect2.west);
            result.east = Math.Min(rect1.east, rect2.east);
            result.south = Math.Max(rect1.south, rect2.south);
            result.north = Math.Min(rect1.north, rect2.north);
            return result;
        }
    }
}
